#include <stdio.h>
#include <stdlib.h>

#define SIZE 10
// 定义栈大小
typedef struct
{
    char data[SIZE];
    int top;
} Strack;

Strack *init()
{
    Strack strack;
    strack.top = -1;

    Strack *address = &strack;

    return address;
}

// 入栈
void pushStrack(Strack *struck, char value)
{
    printf("push strack top=%d, val=%c \n", struck->top, value);

    struck->top = struck->top + 1;
    //进行入栈
    struck->data[struck->top] = value;
}
// 打印当前栈
void printStrack(Strack *strack)
{
    printf("print strack top =%d \n", strack->top);

    for (int i = 0; i <= strack->top; i++)
    {
        printf("print index=%d , val=%c \n", i, strack->data[i]);
    }
    printf("print strack top =%d \n", strack->top);
}
// 出栈
char popStrack(Strack *strack)
{   
    int top = strack->top;
    char item = strack->data[top];
    strack->top = strack->top - 1;

    return item;
}

int main()
{
    Strack *strack = init();
    pushStrack(strack, 'a');
    pushStrack(strack, 'b');
    pushStrack(strack, 'c');

    printStrack(strack);
    printf("------------------ \n");

    char item = popStrack(strack);
    //printf("strack pop val=%c \n", item);
    //printStrack(strack);

    return 0;
}